package com.ktjiaoyu.controller;

import com.ktjiaoyu.entity.GoodsCategory;
import com.ktjiaoyu.entity.SysRole;
import com.ktjiaoyu.entity.SysUser;
import com.ktjiaoyu.service.CategoryService;
import com.ktjiaoyu.service.impl.SysUserServiceImpl;
import com.ktjiaoyu.utils.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/main/category")
public class GoodsCategoryController extends BaseController{
    private static final Logger LOGGER= LoggerFactory.getLogger(SysUserServiceImpl.class);

    @Autowired
    private CategoryService categoryService;

    @RequestMapping("list")
    public String getAll(Model model){
        Page<GoodsCategory> page=null;
        try {
            List<GoodsCategory> goodsCategoryList=categoryService.getAll();
            model.addAttribute("list",goodsCategoryList);
        }catch (Exception e){
            LOGGER.error("GoodsCategoryController中的getAll方法执行发生错误。",e);
            throw new RuntimeException(e);
        }
        return "category/list";
    }

//    @RequestMapping("/view/{id}")
//    public String FindById(@PathVariable("id") Long id,Model model){
//        try {
//            GoodsCategory goodsCategory=categoryService.findById(id);
//            model.addAttribute("sysRole",sysRole);
//        }catch (Exception e){
//            LOGGER.error("SysRoleController中的roleById方法执行发生错误。",e);
//            throw new RuntimeException(e);
//        }
//        return "role/list";
//    }
}
